package it.globalbase.tool;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class AppProperties {
	private static final String DEFAULT_PROPERTIES_NAME = "app.properties";

	public static final Properties loadProperties(String propertiesName)
			throws IOException {
		Properties properties = new Properties();
		InputStream is = AppProperties.class.getClassLoader().getResourceAsStream(propertiesName);
		properties.load(is);

		return properties;
	}

	public static final Properties loadProperties() throws IOException {
		Properties properties = new Properties();
		InputStream is = AppProperties.class.getClassLoader().getResourceAsStream(DEFAULT_PROPERTIES_NAME);
		properties.load(is);

		return properties;
	}

	public static String get(String key) throws IOException {
		return loadProperties().getProperty(key);
	}

	public static String get(String propertiesName, String key)
			throws IOException {
		return loadProperties(propertiesName).getProperty(key);
	}
}
